﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Mvc.Html;

namespace Auction_Intranet.Helpers
{
    public static class ActionLinkHelpers
    {
        public static MvcHtmlString SelectedActionLink(this HtmlHelper helper, string linkText, string actionName, string controllerName)
        {
            var controller = (string)helper.ViewContext.RouteData.Values["controller"];
            if (string.Compare(controller, controllerName, StringComparison.InvariantCultureIgnoreCase) == 0)
            {
                return helper.ActionLink(linkText, actionName, controllerName, null, new { Class = "selected" });
            }

            return helper.ActionLink(linkText, actionName, controllerName);
        }

        public static MvcHtmlString SelectedActionLink(this HtmlHelper helper, string linkText, string actionName, string controllerName, string htmlattr)
        {
            var controller = (string)helper.ViewContext.RouteData.Values["controller"];
            if (string.Compare(controller, controllerName, StringComparison.InvariantCultureIgnoreCase) == 0)
            {
                return helper.ActionLink(linkText, actionName, controllerName, null, new { Class = "selected ", Title = htmlattr });
            }

            return helper.ActionLink(linkText, actionName, controllerName,null, new { @title = htmlattr });
        }
    }
}